<?php
require_once '../../../core/fcCommon.php';
require_once '../../../core/fcORM_raschada_rx.php';
require_once '../../../log/Logger.php';
Logger::configure('../../../log4php.xml');
$logger = Logger::getLogger(__FILE__);

$json = getJsonFromRequest();
$obj = new Entity("raschada_rx_lot");
foreach($json as $key => $value){
    $obj->put($key, $value);
}
$logger->debug($obj->get('drug_lot_date'));
$util = new DojoUtil();
$newDateStr = $util->datetimeFromDojo($obj->get('drug_lot_date'));
$logger->debug($newDateStr);

//$d->sub(date_interval_create_from_date_string('543 years'));
//date_sub($d, date_interval_create_from_date_string('543 years'));
$obj->put('drug_lot_date', $newDateStr);
$obj->put('update_datetime', date("Y-m-d H:i:s", time() - 3600));

$condition = new Map();
$condition->put("drug_lot_id", $json["drug_lot_id"]);

$conn = new Connection();
$conn->merge($obj, $condition);

echo $obj->toJson();
?>
